home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / CPP / WFC010.ZIP / TEST / TCNET.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-18  |  5.0 KB  |  131 lines

  1. #include "test.h"
  2. #pragma hdrstop
  3.  
  4. void test_CNetWorkstation( LPCTSTR machine_name )
  5. {
  6.    CNetWorkstation workstation( machine_name );
  7.  
  8.    CWorkstationInformation workstation_information;
  9.  
  10.    if ( workstation.EnumerateInformation() == TRUE )
  11.    {
  12.       printf( "Workstation Machine Information:\n" );
  13.  
  14.       while( workstation.GetNext( workstation_information ) == TRUE )
  15.       {
  16.          printf( " PlatformID            - %d\n",               workstation_information.PlatformID            );
  17.          printf( " Name                  - \"%s\"\n", (LPCTSTR) workstation_information.ComputerName          );
  18.          printf( " LANGroup              - \"%s\"\n", (LPCTSTR) workstation_information.LANGroup              );
  19.          printf( " MajorVersion          - %d\n",               workstation_information.MajorVersion          );
  20.          printf( " MinorVersion          - %d\n",               workstation_information.MinorVersion          );
  21.          printf( " LANRoot               - \"%s\"\n", (LPCTSTR) workstation_information.LANRoot               );
  22.          printf( " NumberOfLoggedOnUsers - %d\n",               workstation_information.NumberOfLoggedOnUsers );
  23.       }
  24.    }
  25.    else
  26.    {
  27.       DWORD error_code = workstation.GetErrorCode();
  28.  
  29.       CString error_message;
  30.  
  31.       Convert_NERR_Code_to_String( error_code, error_message );
  32.  
  33.       printf( "CNetWorkstation.Enumerate( workstation_information ), ErrorCode == %d \"%s\"\n", error_code, (LPCTSTR) error_message );
  34.    }
  35.  
  36.    CWorkstationUser user_information;
  37.  
  38.    if ( workstation.EnumerateUsers() == TRUE )
  39.    {
  40.       printf( "\nWorkstation User Information:\n" );
  41.  
  42.       WCHAR wide_machine_name[ 256 ];
  43.       WCHAR wide_domain_name[ 256 ];
  44.  
  45.       LPSTR buffer = NULL;
  46.  
  47.       ZeroMemory( wide_machine_name, sizeof( wide_machine_name ) );
  48.       ZeroMemory( wide_domain_name,  sizeof( wide_domain_name  ) );
  49.  
  50.       while( workstation.GetNext( user_information ) == TRUE )
  51.       {
  52.          ASCII_to_UNICODE( (LPCTSTR) user_information.LogonServer, wide_machine_name );
  53.          ASCII_to_UNICODE( (LPCTSTR) user_information.LogonDomain, wide_domain_name  );
  54.  
  55.          NetGetDCName( wide_machine_name, wide_domain_name, (LPBYTE *) &buffer );
  56.          UNICODE_to_ASCII( (LPCWSTR) buffer, buffer );
  57.  
  58.          printf( " User Name     - \"%s\"\n",   (LPCTSTR) user_information.UserName     );
  59.          printf( " Logon Domain  - \"%s\" [%s]\n",   (LPCTSTR) user_information.LogonDomain, (LPSTR) buffer );
  60.          printf( " Other Domains - \"%s\"\n",   (LPCTSTR) user_information.OtherDomains );
  61.          printf( " Logon Server  - \"%s\"\n\n", (LPCTSTR) user_information.LogonServer  );
  62.       }
  63.    }
  64.    else
  65.    {
  66.       DWORD error_code = workstation.GetErrorCode();
  67.  
  68.       CString error_message;
  69.  
  70.       Convert_NERR_Code_to_String( error_code, error_message );
  71.  
  72.       printf( "CNetWorkstation.Enumerate( user_information ), ErrorCode == %d \"%s\"\n", error_code, (LPCTSTR) error_message );
  73.    }
  74.  
  75.    user_information.Empty();
  76.  
  77.    if ( workstation.GetCurrentUser( user_information ) == TRUE )
  78.    {
  79.       printf( "\nWorkstation Current User Information:\n" );
  80.       printf( " User Name     - \"%s\"\n", (LPCTSTR) user_information.UserName     );
  81.       printf( " Logon Domain  - \"%s\"\n", (LPCTSTR) user_information.LogonDomain  );
  82.       printf( " Other Domains - \"%s\"\n", (LPCTSTR) user_information.OtherDomains );
  83.       printf( " Logon Server  - \"%s\"\n", (LPCTSTR) user_information.LogonServer  );
  84.    }
  85.    else
  86.    {
  87.       DWORD error_code = workstation.GetErrorCode();
  88.  
  89.       CString error_message;
  90.  
  91.       Convert_NERR_Code_to_String( error_code, error_message );
  92.  
  93.       printf( "CNetWorkstation.GetCurrentUser( user_information ), ErrorCode == %d \"%s\"\n", error_code, (LPCTSTR) error_message );
  94.    }
  95.  
  96.    CWorkstationTransport transport_information;
  97.  
  98.    if ( workstation.EnumerateTransports() == TRUE )
  99.    {
  100.       printf( "\nWorkstation Transport Information:\n" );
  101.  
  102.       while( workstation.GetNext( transport_information ) == TRUE )
  103.       {
  104.          printf( " Quality of Service         - %d\n", transport_information.QualityOfService        );
  105.          printf( " Number Of Virtual Circuits - %d\n", transport_information.NumberOfVirtualCircuits );
  106.          printf( " Name                       - \"%s\"\n", (LPCTSTR) transport_information.Name      );
  107.          printf( " Address                    - \"%s\"\n", (LPCTSTR) transport_information.Address   );
  108.    
  109.          if ( transport_information.WANish == TRUE )
  110.          {
  111.             printf( " WANish                     - TRUE\n\n" );
  112.          }
  113.          else
  114.          {
  115.             printf( " WANish                     - FALSE\n\n" );
  116.          }
  117.       }
  118.    }
  119.    else
  120.    {
  121.       DWORD error_code = workstation.GetErrorCode();
  122.  
  123.       CString error_message;
  124.  
  125.       Convert_NERR_Code_to_String( error_code, error_message );
  126.  
  127.       printf( "CNetWorkstation.Enumerate( transport_information ), ErrorCode == %d \"%s\"\n", error_code, (LPCTSTR) error_message );
  128.    }
  129. }
  130.  
  131.